<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>模版语法：for</title>
</head>
<body>
<h2>for循环语句</h2>
=====================
{% for like in likes %}
	<p>{{ like }}</p>
{% endfor %}
=====================
<h4>带empty的for循环</h4>
{% for like in likes1 %}
	<p>{{ like }}</p>
{% empty %}
    <p>likes1为空或不存在</p>
{% endfor %}
======================
<h4>下标</h4>
{% for like in likes %}
	<p>
        counter0表示从0开始的下标：{{ forloop.counter0 }}
        counter表示从1开始的下标：{{ forloop.counter }}
        revcounter0表示从0开始倒序下标：{{ forloop.revcounter0 }}
        revcounter表示从1开始倒序下标：{{ forloop.revcounter }}
        {#    判断循环的第一个和最后一个    #}
        {% if forloop.first %}
            <b> - first</b>
        {% endif %}
    
        {% if forloop.last %}
        <b> - last</b>
        {% endif %} 
    </p>
    
{% endfor %}
===============================
<h4>嵌套循环</h4>
<table border="1" width="500">
{% for star in stars %}
    <tr>
        {% for s in star %}
        	<td>{{ s }}({{ forloop.parentloop.counter }}, {{ forloop.counter }})</td>
        {% endfor %}
    </tr>
{% endfor %}
</table>



</body>
</html>